<%@ page language="java" pageEncoding="UTF-8" %>
<%@ page import="com.ncr.teradata.bireport.*" %>
<%@ page import="java.util.Enumeration" %>

<%
	String action = "";
	String[] rptNames = new String[]{};
	//页面获取到的参数
	Enumeration e = request.getParameterNames();
	while (e.hasMoreElements())
	{
		String hdName = (String)e.nextElement();
		if (hdName.equals("action"))
			action = request.getParameter(hdName);
		if (hdName.equals("rptName"))
			rptNames = request.getParameterValues(hdName);
	}
	
	ReportServer server = ReportServer.getInstance();
	String[] reportNames = server.getCachedReportNames();
	String processResult = "";
	if (action.equals("refreshReport")){
		for (int i = 0; i < rptNames.length; i++){
			server.doScheduler(rptNames[i]);
		}
		processResult = "报表缓存刷新成功！";
	}
	if (action.equals("refreshMetadata")){
		server.buildReportMetaData();
		processResult = "报表配置文件刷新成功！";
	}
%>

<html>
<head>
	<title>BIReport管理</title>
	<link href="../css/style.css" rel="stylesheet" type="text/css"/>
    <link href="../css/font.css" rel="stylesheet" type="text/css">
<SCRIPT>
	function refreshReport(){
		if(!confirm("您确定要刷新报表缓存吗？"))
			return;
		document.form1.action = "bireport_manage.jsp?action=refreshReport";
		document.form1.submit();
	}
	
	function refreshMetadata(){
		if(!confirm("您确定要刷新报表配置文件吗？"))
			return;
		document.form1.action = "bireport_manage.jsp?action=refreshMetadata";
		document.form1.submit();
	}
	
	function selectAll(obj)
	{
		var num = <%= reportNames.length / 2 %>;
		var flag = obj.checked;
		for(var i=0;i<num;i++)
		{
			if(flag)
				document.all.rptName[i].checked = true;
			else
				document.all.rptName[i].checked = false;
		}
	}
</SCRIPT>
</head>
<body>
<form name="form1" action="<%=request.getContextPath()%>/jsp/hnedw/manage_report_cache.jsp" method="post">
	<table width="100%" height="100%"  border="0" align="center" cellpadding="0" cellspacing="1" >
		<tr>
			<td valign='top' align='right' bgcolor="#FFFFFF"> 
				<table width="100%" border="0" align="center" cellpadding="1" cellspacing="2">
					<tr class="fontblue" width="100%" align="left">
						<td><img src="../images/title_left.gif" width="10" height="10"></td>
						<td valign='center' width="15%">BIReport管理：</td>
                        <td align='left' width="15%">
                        	<input type="button" class="button2" value="刷新报表缓存" onclick="refreshReport();">
                    	</td>
                    	<td align='left' width="100%">
                        	<input type="button" class="button2" value="刷新报表配置文件" onclick="refreshMetadata();">
                    	</td>
					</tr>
				</table>
				<div class="font12" style="color:#ff0000" align="left"><%= processResult %><div>
				<table border=1 width=100% class="tablestyle1" style='table-layout:fixed' cellspacing='0' cellpadding='0' bordercolordark='#ccffff' bordercolorlight='#9999cc'>
					<tr align="left" height="22">
						<td width="20" align="center">0</td>
						<td>&nbsp;<input type="checkbox" class="inputboxwhite1" onclick="selectAll(this);">&nbsp;全选</td>
					</tr>
				<%
					for (int i = 0; i < reportNames.length; i = i + 2){
				%>
					<tr align="left" height="22">
						<td width="20" align="center"><%= i / 2 + 1 %></td>
						<td>&nbsp;<input type="checkbox" class="inputboxwhite1" name="rptName" value="<%= reportNames[i] %>">&nbsp;<%= reportNames[i + 1] %></td>
					</tr>
				<% } %>
				</table>
			</td>
		</tr>
		
	</table>
</form>
</body>
</html>


